import { ref } from 'vue'
import { adapter, request } from '@/request'
import { residueNumberde } from '@/core/api/account'
import type { RequestWrapper } from '@/core/interfaces/common'

export interface Params {
  orderId: number
}

export default function residueNumberdeFn() {
  const service = adapter<RequestWrapper<any>>(request)
  const loading = ref(false)

  const fetch = (params: Params) => {
    const { url, method } = residueNumberde()
    loading.value = true

    return service({
      config: {
        url,
        method,
        params
      },
      done: () => {
        loading.value = false
      }
    })
  }

  return [undefined, fetch, loading] as const
}
